/*
 * v1.1 by jetsum tonydon
 * netbeansIDE 7.1
 */
package txdnet.util.concurrent;
import java.util.Queue;
import java.util.concurrent.*;
/**
 *
 * @author txdnet
 */
public class ReturnQueueWaitHandler implements RejectedExecutionHandler{

    private Queue queue;
    
    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        // 将暂时无法处理的任务添加到缓冲队列中
        // System.out.println(r.toString()+" 加入缓冲队列...");
        // 此处可以判断是否需要丢弃
        if(queue!=null) {
            queue.offer(r);
        }
    }

    /**
     * @return the queue
     */
    public Queue getQueue() {
        return queue;
    }

    /**
     * @param queue the queue to set
     */
    public void setQueue(Queue queue) {
        this.queue = queue;
    }
    
}
